<?php
include 'db.php';
	
$username=$_GET['u'];
$subject=$_GET['s'];
$type='tutor';

if(!mysql_query("INSERT INTO `sessions` SET `tutor`='{$username}', `subject`='{$subject}', `rating`=0, `starttime`=NOW()"))
	echo "Error:" . mysql_error();

$q=mysql_query("SELECT sessionid FROM `sessions` ORDER BY sessionid DESC LIMIT 1" );
while($data = mysql_fetch_row($q)){
	if(!mysql_query("INSERT INTO `messages` SET `username`='{$username}',`sessionid`=$data[0], `message`='Hello, I am {$username}, how can I help you in {$subject}?'"))
		echo "Error:" . mysql_error();
	echo $data[0];
}

mysql_close($link);
?>
 
